package jwdt.xadmin.custom.action;


import jwdt.common.action.BaseAction;
import jwdt.xadmin.custom.bean.TCustomLog;
import jwdt.xadmin.custom.service.CustomLogManageService;
import jwdt.xadmin.system.bean.TUser;

import com.ezerg.db.ext.PageUtil;
import com.ezerg.web.Form;
import com.ezerg.web.Module;
import com.ezerg.web.Page;
import com.ezerg.web.annotation.Controller;
import com.ezerg.web.annotation.RequestMapping;

@Controller("/xadmin/custom")
public class CustomLogManageAction extends BaseAction {
	private CustomLogManageService customLogManageService = (CustomLogManageService)app.getBean("customLogManageService");
	
	@RequestMapping("/listCustomLog")
	public Page doListVote(Form f, Module m) throws Exception {
		PageUtil pu = (PageUtil)f.copy2Class(PageUtil.class);
		TCustomLog tc = (TCustomLog)f.copy2Class(TCustomLog.class);
		return m.getWritePage(f, customLogManageService.doList(pu,tc).toJson());
	}
	
	@RequestMapping("/addCustomLog")
	public Page doAddact(Form f, Module m) throws Exception {
		TUser userInfo = (TUser) f.getSession("userInfo");
		TCustomLog obj = (TCustomLog)f.copy2Class(TCustomLog.class);
		return m.getWritePage(f, customLogManageService.doAddact(obj,userInfo.getUserid()));
	}
	
	@RequestMapping("/editCustomLog")
	public Page doEditact(Form f, Module m) throws Exception {
		TCustomLog obj = (TCustomLog)f.copy2Class(TCustomLog.class);
		String contact = f.getString("contact");
		Integer id = f.getInt("id");
		return m.getWritePage(f, customLogManageService.doEditact(obj,id,contact));
	}
	
	@RequestMapping("/customLogWindow")
	public Page doLoad(Form f, Module m) throws Exception {
		int customid = f.getInt("customid");
		int id = f.getInt("id");
		f.add("obj", customLogManageService.doLoad(id));
		f.add("customid", customid);
		return m.defaultPage();
	}
	
	@RequestMapping("/delCustomLog")
	public Page doDel(Form f, Module m) throws Exception {
		int id = f.getInt("id");
		return m.getWritePage(f, customLogManageService.doDelact(id));
	}
	
}
